// 解析歌词
export default function parseLyric(lyric) {
  const lyricInfo = []
  const timeRegExp = /\[(\d{2}):(\d{2}).(\d{2,3})\]/   // 正则匹配时间
  // 拆分多个字符串
  const lyricStrings = lyric.split("\n")
  // 遍历组成对象
  for (const lyricString of lyricStrings) {
    const timeResult = (timeRegExp.exec(lyricString));
    if(!timeResult) continue
    const minute = timeResult[1] * 60 * 1000
    const second = timeResult[2] * 1000
    const millsecond = timeResult[3].length == 2 ? timeResult[3] * 10 : timeResult[3] * 1
    // 得到毫秒级的时间
    const time = minute+second+millsecond
    // 将时间戳替换 ""
    const text = lyricString.replace(timeResult[0],'')
    lyricInfo.push({time,text})
  }
  return lyricInfo
}